﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace SDT.Site
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = 0 }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            routes.MapRoute(
                "UrlRewrite", // Route name
                "{controller}/{action}/{id}/{title}", // URL with parameters
                new { controller = "Article", action = "Details", id = 0, title = (string)null }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            ///
            /// Author: Takamaru Nguyen
            /// Date: 10/08/2011
            /// For type: /Controller/Action/id/pubYN
            ///
            routes.MapRoute(
                "Default_String", // Route name
                "{controller}/{action}/{source}/{page}", // URL with parameters
                new { controller = "Home", action = "Index", source = "", page = 0 }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
           );
            routes.MapRoute(
                "Product",
                "Product/{action}/{id}/{catid}/{cityid}/{distrid}/{areaid}/{priceid}/{projectid}/{timeid}",
                new { controller = "Product", action = "Index", id = 0, catid = 0, cityid = 0, distrid = 0, areaid = 0, priceid = 0, projectid = 0, timeid = 0 }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            routes.MapRoute(
               "Demand",
               "Demand/{action}/{id}/{catid}/{cityid}/{distrid}/{areaid}/{priceid}/{projectid}/{timeid}",
               new { controller = "Demand", action = "Index", id = 0, catid = 0, cityid = 0, distrid = 0, areaid = 0, priceid = 0, projectid = 0, timeid = 0 }, // Parameter defaults
               new string[] { "SDT.Site.Controllers" } // Parameter defaults
           );
            routes.MapRoute(
               "Project",
               "Project/{action}/{id}/{cityid}/{distrid}",
               new { controller = "Project", action = "list", id = 0, cityid = 0, distrid = 0 }
           );
            routes.MapRoute(
              "Company",
              "company/{action}/{id}/{cityid}/{distrid}",
              new { controller = "company", action = "directories", id = 0, cityid = 0, distrid = 0 }
          );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}